<template>
	<view>
		<u-swiper :list="dataAll.images_text" height="200" radius="0" indicator circular></u-swiper>
		<view class="mainpadding xiaobai" style="background-color: #ff7200;">{{dataAll.name}}</view>
		<u-tabs lineColor="#ff7200" :scrollable="false" :current="Number(tabsid) - 1" :list="tabList" @click="clickfn"></u-tabs>
		<view class="mainpadding">
			<view v-if="tabsid==1">
				<u-parse :content="dataAll.ydlc_content"></u-parse>
			</view>
			<view v-if="tabsid==2">
				<u-parse :content="dataAll.zysx_content"></u-parse>
			</view>
			<view v-if="tabsid==3">
				<u-parse :content="dataAll.sfbz_content"></u-parse>
			</view>
			<view class="flexright margin_top">
				<view class="margin_right" @click="collect">
					<u-icon name="star" color="#999" v-if="dataAll.is_sc==0" size="25"></u-icon>
					<u-icon name="star-fill" v-if="dataAll.is_sc==1" color="#ff7200" size="25"></u-icon>
				</view>
				<view class="margin_right">
					<button open-type="share" hover-class="none">
						<u-icon name="share-square" color="#ff7200" size="25"></u-icon>
					</button>
				</view>
				<view class="flexleft radius lxwmbox" @click="kefushow=true">
					<u-icon name="server-man" color="#fff" size="16"></u-icon>
					<view class="xiaobai">联系我们</view>
				</view>
			</view>
			<view class="margin_top">
				<u-divider text="分割线" textColor="#ff7200" lineColor="#ff7200" :dot="true"></u-divider>
			</view>
			<view class="flexbetween margin_top">
				<view class="titletext bold hei_text">类似{{dataAll.category.name}}推荐</view>
				<view class="listbtnhuang" @click="morejx()">更多</view>
			</view>
			<view class="flexbetween flex_wrap">
				<view class="tehui margin_top" v-for="item in list.data" :key="item.id" style="height: auto;"
					@click="jumpurl('/pages/index/detail?id=',item.id)">
					<view class="tehui" style="width: 100%;">
						<image :src="item.image_text" class="tehuiimage" mode=""></image>
						<view class="fuwulable" v-if="item.is_th==1">特惠</view>
						<view class="rightidnum xiaobai">ID：{{item.id}}</view>
					</view>
					<view class="yihang main_size hei_text margin_top1">{{item.name}}</view>
					<view class="xiaohuang yihang margin_top1" v-if="!is_login" @click.stop="gologin">查看报价</view>
					<view class="xiaohuang yihang margin_top1" v-if="is_login">{{item.price}}</view>
				</view>
			</view>
		</view>
		<kefu :kefushow="kefushow" @closed="kefushow=false"></kefu>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				kefushow: false,
				tabsid: 1,
				tabList: [{
					name: '预定流程',
					id: 1
				}, {
					name: '注意事项',
					id: 2
				}, {
					name: '收费标准',
					id: 3
				}, ],
				listid: "",
				dataAll: {},
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				is_login:false,
			}
		},
		onLoad(options) {
			this.listid = options.id
			this.getDetail()
		},
		onShow() {
			this.tabsid = 2
			this.tabsid = 1
			this.is_login = httpRequest.checkIsLogin();
		},
		onShareAppMessage: function(options) {
			return {
				title: '制片宝',
				imageUrl: '',
				path: '/pages/index/detail?id='+this.listid
			}
		},
		onShareTimeline: function() {
			return {
				title: '制片宝',
				imageUrl: '',
				path: '/pages/index/detail?id='+this.listid
			}
		},
		methods: {
			gologin(){				uni.navigateTo({					url:"/pages/login/login"				})			},
			clickfn(e){
				if(!this.is_login && e.id==3){
					this.gologin()
				}
				this.tabsid = e.id
			},
			collect(){
				httpRequest.request('user/cjCollect', 'GET', {
					cj_id: this.listid
				}, false, false, true).then(res => {
					httpRequest.toast(res.msg);
					if(res.code==1){
						this.dataAll.is_sc = this.dataAll.is_sc==1?0:1
					}
				})
			},
			morejx(){
				uni.switchTab({
					url:"/pages/changjing/changjing"
				})
			},
			getDetail() {
				httpRequest.request('index/cjDetail', 'GET', {
					id: this.listid
				}, false, false, true).then(res => {
					uni.setNavigationBarTitle({
						title:res.data.name
					})
					this.dataAll = res.data

					this.init()
				})
			},
			init(isPage, page) {
				let _this = this;
				let data = {
					page: page || 1,
					limit: _this.limit,
					category_id: this.dataAll.category.id,
				}
				httpRequest.request('index/cjIndex', 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}

				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			jumpurl(url, id) {
				uni.navigateTo({
					url: url + id
				})
			},
		}
	}
</script>

<style>
	.lxwmbox {
		padding: 10rpx 30rpx;
		background-color: #ff7200;
		border-radius: 10rpx;
	}
</style>